package 数组.easy;

import java.util.Arrays;

/**
 * @author Lw中
 * @date 2020/8/13 10:15
 */
public class BaLuQi {

    public static int[][] transpose(int[][] A) {
        int m = A.length;
        int n = A[0].length;
        int[][] B = new int[n][m];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                B[j][i] = A[i][j];
            }
        }
        return B;
    }

    public static void main(String[] args) {
        int[][] test = {{1,2,3}, {4,5,6}, {7,8,9}};
        int[][] transpose = transpose(test);
        // 遍历输出二维数组方法
        for (int i = 0; i < transpose.length; i++) {
            System.out.println(Arrays.toString(transpose[i]));
        }
    }

}
